<style type="text/css">
#stock-order,#stock-info {
	margin-top: 10px;
}
#scanForm {
	padding-bottom: 5px;
}
.table-responsive a, .table-responsive a:hover {
	text-decoration: none;
	cursor: pointer;
}
</style>
<div class="pageheader">
	<h2>
		<i class="fa fa-pencil-square"></i>日志管理
	</h2>
	<div class="breadcrumb-wrapper">
		<span class="label">你所在的位置：</span>
		<ol class="breadcrumb">
			<li><a href="/index">ERP管理系统</a></li>
			<li>日志管理</li>
			<li>网站订单日志</li>
			<li class="active">查看</li>
		</ol>
	</div>
</div>
<div class="contentpanel">
<div class="main">
    <div class="table-responsive">
        <div><label>订单信息：</label><code>订单号为<?php echo $this->id;?>,来自网站<?php echo $this->site;?></code><a target="_blank" href="<?php echo $this->url(array('controller'=>'log','action'=>'omodify','oid' =>$this->id,'site'=>$this->site),null,true)?>">【点击这里可进入修改页面】</a></div>
        <table id="order-log" class="table table-bordered table-hover">
            <thead>
                <tr class="info">
                    <th>SKU</th>
                    <th>产品名称</th>
                    <th>尺码和数量</th>
                    <th>下单时间</th>
                    <th>状态</th>
                </tr>
            </thead>
            <tbody>
            <?php 
            if ($this->logList){ 
                foreach ($this->logList as $v){
            ?>
            <tr id="<?php echo $v['sku'];?>">
                <td><?php echo $v['sku'];?><input type="text" hidden="hidden" value="<?php echo $v['sku'];?>" name="o_sku[]"></td>
                <td><?php echo $v['title'];?></td>
                <td>
                    <?php 
                    $info = json_decode($v['info'], true);
                    
                    foreach($info as $_v){
                        $act = '';
                        if ($v['info_stock'] == 'add') {
                        	$act = '+';	
                        } else {
                        	$act = '-';	
                        }
                        echo '尺码: ' . $_v[0] . ', 库存: ' . $act . stripslashes($_v[1]) . '<br/>';
                    ?>
                    <input type="text" hidden="hidden" value="<?php echo $_v[0];?>" name="o_size[<?php echo $v['sku'];?>][]">
                    <input class="size_num_<?php echo $_v[0];?>" name="onum_<?php echo $v['sku'];?>_<?php echo $_v[0];?>" type="text" hidden="hidden" value="<?php echo $_v[1];?>">
                    <input class="check_num_<?php echo $_v[0];?>" name="cnum_<?php echo $v['sku'];?>_<?php echo $_v[0];?>" hidden="hidden" type="text" value="0">
                    <?php }?>
                    <?php 
                    foreach (json_decode($v['lack'],true) as $vl){
                        if(($vl[1]>0) && $v['statu']){
                        	echo '<p style="display:inline;" class="text-danger">缺:'.$vl[0].'/'.$vl[1].'&nbsp;&nbsp;</p>';
                        }
                    }
                    ?>
				</td>
				<td><?php echo $v['add_time']; ?></td>
				<td>
				    <?php
				    switch ($v['statu'])
				        {
				        	case 1:
				        		echo '<span class="status label label-danger">分拣中、缺货中</span>';
				        		break;
				        	case 2:
				        		echo '<span class="status label label-info">分拣完、未处理</span>';
				        		break;
				        	case 3:
				        		echo '<span class="status label label-primary">分拣完、处理中</span>';
				        		break;
				        	case 4:
				        		echo '<span class="status label label-success">分拣完、处理完</span>';
				        		break;
				        	case 5:
				        		echo '<span class="status label label-default">已处理退货</span>';
				        		break;
				        	default:
				        		echo '<span class="status label label-warning">未分拣、未处理</span>';
				        }
				    ?>
				</td>
			</tr>
			<?php
                }
            }
			?> 
            </tbody>
        </table>
    </div>
    <div class="table-responsive">
        <div><label>已经分拣的项：</label><code><?php if(empty($this->sortloglist))echo '无';?></code></div>
        <?php if(!empty($this->sortloglist)){?>
        <table id="sort-log" class="table table-bordered table-hover">
            <thead>
                <tr class="info">
                    <th>SKU</th>
                    <th>名称</th>
                    <th>尺码和数量</th>
                    <th>赠品</th>
                    <th>分拣员</th>
                    <th>分拣时间</th>
                    <th>操作员</th>
                    <th>操作时间</th>
                    <th>状态</th>
                </tr>
            </thead>
            <tbody>
                <?php 
                if ($this->sortloglist){
                	foreach ($this->sortloglist as $v){
                ?>
                <tr class="<?php echo $v['sku'].$v['size'];?>">
                    <td><?php echo $v['sku'];?></td>
                    <td><?php echo $v['title'];?></td>
                    <td><?php echo '尺码: ' . $v['size'] . ', 数量: 1 <br/>'; ?></td>
				    <td><?php if($v['isgift']){echo '是';}else{echo '否';}?></td>
				    <td><?php echo $v['adduser']; ?></td>
				    <td><?php echo $v['add_time']; ?></td>
				    <td><?php if(empty($v['operuser'])){echo '无操作';}else{echo $v['operuser'];} ?></td>
				    <td><?php if(empty($v['oper_time'])){echo '无操作';}else{echo $v['oper_time'];} ?></td>
				    <td>
				        <?php
				        switch ($v['statu'])
				        {
				        	case 1:
				        		echo '<span class="status label label-primary">已操作、未打包</span>';
				        		break;
				        	case 2:
				        		echo '<span class="status label label-success">已打包</span>';
				        		break;
				        	default:
				        		echo '<span class="status label label-warning">未处理</span>';
				        }
				        ?>
				    </td>
			    </tr>
			    <?php
                	}
                }
			    ?>
            </tbody>
        </table>
        <?php }?>
    </div>
    <div class="table-responsive">
        <div><label>产生的包裹：</label><code><?php if(empty($this->packloglist))echo '无';?></code></div>
        <?php if(!empty($this->packloglist)){?>
        <table id="pack-log" class="table table-bordered table-hover">
            <thead>
                <tr class="info">
                    <th>包裹</th>
                    <th>快递单号</th>
                    <th>包裹内容</th>
                    <th>打包员</th>
                    <th>打包时间</th>
                </tr>
            </thead>
            <tbody>
            <?php 
                if ($this->packloglist){
                	$i = 1;
                	foreach ($this->packloglist as $v){
                ?>
                <tr>
                    <td><?php echo $i++;?></td>
                    <td><?php echo $v['bill_id'];?><br/><?php echo $v['memo']; ?></td>
                    <td>
                        <table class="table table-bordered table-hover">
                            <thead><tr><th>SKU</th><th>名称</th><th>尺码数量</th><th>赠品</th><th>分拣员</th><th>分拣时间</th><th>操作员</th><th>操作时间</th><th>状态</th></tr></thead>
                            <tbody>
                            <?php
                            $sort_ids = json_decode($v['sort_ids']);
                            foreach ($sort_ids as $sid){
                            	foreach ($this->sortloglist as $vv){
                        	    	if(intval($vv['id']) == intval($sid)){
                            ?>
                                <tr><td><?php echo $vv['sku'];?></td>
                                <td><?php echo $vv['title'];?></td>
                                <td><?php echo '尺码: ' . $vv['size'] . ', 数量: 1 <br/>'; ?></td>
				                <td><?php if($vv['isgift']){echo '是';}else{echo '否';}?></td>
				                <td><?php echo $vv['adduser']; ?></td>
				                <td><?php echo $vv['add_time']; ?></td>
				                <td><?php if(empty($vv['operuser'])){echo '无操作';}else{echo $vv['operuser'];} ?></td>
				                <td><?php if(empty($vv['oper_time'])){echo '无操作';}else{echo $vv['oper_time'];} ?></td>
				                <td>
				                <?php
				                    switch ($vv['statu'])
				                    {
				        	            case 1:
				        		            echo '<span class="status label label-primary">已操作、未打包</span>';
				        		            break;
				        	            case 2:
				        		            echo '<span class="status label label-success">已打包</span>';
				        		            break;
				        	            default:
				        		            echo '<span class="status label label-warning">未处理</span>';
				                    }
				                ?>
				                </td></tr>
                            <?php
                        	    	}
                            	}
                            }
                            ?></tbody>
                        </table>
                    </td>
				    <td><?php echo $v['adduser']; ?></td>
				    <td><?php echo $v['add_time']; ?><br/><?php echo '国家：'.$v['country'];?><br/><?php echo '重量：'.$v['weight']; ?><br/><?php echo '件数：'.$v['piece']; ?></td>
			    </tr>
			    <?php
                	}
                }
			    ?>
            </tbody>
        </table>
        <?php }?>
    </div>
    <div>
        <div><label>备注信息：</label><code><?php if(empty($this->memolist))echo '无';?></code></div>
        <ul class="media-list comment-list">
            <?php 
            foreach ($this->memolist as $v) {
            ?>
            <li class="media">
                <div class="media-body">
                    <small class="text-muted"><?php echo $v['add_user'] . '    ' . $v['add_time'];?></small>
                    <p><?php echo $v['memo'];?></p>
                </div>
            </li>
            <?php } ?>
        </ul>
    </div>
</div>
</div>
